package com.ruoyi.environment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.environment.domain.OpmEnvSewageLicense;
import com.ruoyi.environment.service.IOpmEnvSewageLicenseService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 污水许可资料Controller
 *
 * @author cjie
 * @date 2021-07-23
 */
@Api(tags = " 污水许可资料")
@RestController
@RequestMapping("/opmEnvSewageLicense")
public class OpmEnvSewageLicenseController extends BaseController {
    @Autowired
    private IOpmEnvSewageLicenseService opmEnvSewageLicenseService;

    /**
     * 查询污水许可资料列表
     */
    @ApiOperation(value="查询污水许可资料列表", notes="查询污水许可资料列表")
    @PreAuthorize(hasPermi = "environment:opmEnvSewageLicense:list")
    @GetMapping("/list")
    public TableDataInfo list(OpmEnvSewageLicense opmEnvSewageLicense) {
        startPage();
        List<OpmEnvSewageLicense> list = opmEnvSewageLicenseService.selectOpmEnvSewageLicenseList(opmEnvSewageLicense);
        return getDataTable(list);
    }

    /**
     * 导出污水许可资料列表
     */
    @ApiOperation(value="导出污水许可资料列表", notes="导出污水许可资料列表")
    @PreAuthorize(hasPermi = "environment:opmEnvSewageLicense:export")
    @Log(title = "污水许可资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OpmEnvSewageLicense opmEnvSewageLicense) throws IOException {
        List<OpmEnvSewageLicense> list = opmEnvSewageLicenseService.selectOpmEnvSewageLicenseList(opmEnvSewageLicense);
        ExcelUtil<OpmEnvSewageLicense> util = new ExcelUtil<OpmEnvSewageLicense>(OpmEnvSewageLicense.class);
        util.exportExcel(response, list, "污水许可资料数据");
    }
    /**
     * 获取污水许可资料详细信息
     */
    @ApiOperation(value="获取污水许可资料详细信息", notes="获取污水许可资料详细信息")
    @PreAuthorize(hasPermi = "environment:opmEnvSewageLicense:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(opmEnvSewageLicenseService.selectOpmEnvSewageLicenseById(id));
    }

    /**
     * 新增污水许可资料
     */
    @ApiOperation(value="新增污水许可资料", notes="新增污水许可资料")
    @PreAuthorize(hasPermi = "environment:opmEnvSewageLicense:add")
    @Log(title = "污水许可资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OpmEnvSewageLicense opmEnvSewageLicense) {
        return toAjax(opmEnvSewageLicenseService.insertOpmEnvSewageLicense(opmEnvSewageLicense));
    }

    /**
     * 修改污水许可资料
     */
    @ApiOperation(value="修改污水许可资料", notes="修改污水许可资料")
    @PreAuthorize(hasPermi = "environment:opmEnvSewageLicense:edit")
    @Log(title = "污水许可资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OpmEnvSewageLicense opmEnvSewageLicense) {
        return toAjax(opmEnvSewageLicenseService.updateOpmEnvSewageLicense(opmEnvSewageLicense));
    }

    /**
     * 删除污水许可资料
     */
    @ApiOperation(value="删除污水许可资料", notes="删除污水许可资料")
    @ApiImplicitParam(name = "ids", value = "污水许可资料ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "environment:opmEnvSewageLicense:remove")
    @Log(title = "污水许可资料", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(opmEnvSewageLicenseService.deleteOpmEnvSewageLicenseByIds(ids));
    }
}
